package com.yh.autobio.modules.adatper;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yh.autobio.R;
import com.yh.autobio.common.Time;
import com.yh.autobio.modules.bean.InvoiceBean;

import java.util.Date;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * =========================
 * 版权所有，违法必究
 * 作者：john
 * <p>
 * 工程：WMS
 * <p>
 * 文件名：NotApprovalAdapter
 * <p>
 * 创建时间：2017.04.19.18:05
 * *****************************
 */
public class InvoiceAdapter extends ListBaseAdapter<InvoiceBean> {
    private Context ctx;

    public InvoiceAdapter(Context ctx) {
        this.ctx = ctx;
    }

    @Override
    protected View getRealView(int position, View convertView, ViewGroup parent) {
        ViewHolder vh = null;
        if (convertView == null || convertView.getTag() == null) {
            convertView = View.inflate(ctx, R.layout.fragment_invoice_item, null);
            vh = new ViewHolder(convertView);
            convertView.setTag(vh);
        } else {
            vh = (ViewHolder) convertView.getTag();
        }

        InvoiceBean data = mDatas.get(position);
        vh.setData(data);

        return convertView;
    }

    class ViewHolder {
        @InjectView(R.id.tv_djbh)
        TextView tvDjbh;
        @InjectView(R.id.tv_shdw)
        TextView tvShdw;
        @InjectView(R.id.tv_shdz)
        TextView tvShdz;
        @InjectView(R.id.tv_khmc)
        TextView tvKhmc;
        @InjectView(R.id.tv_fhrq)
        TextView tvFhrq;

        public ViewHolder(View view) {
            ButterKnife.inject(this, view);
        }

        public void setData(InvoiceBean data) {
            tvDjbh.setText(data.getFbillno());
            tvShdw.setText(data.getFReceive());
            tvShdz.setText(data.getFaddress());
            tvKhmc.setText(data.getFOrganization());
            tvFhrq.setText(data.getFDate().split("T")[0]);
        }
    }
}
